
#ifndef __ANSPHONECALLMAKER_H__
#define __ANSPHONECALLMAKER_H__

#include <etel.h>

class MAnsPhoneCallMakerObserver
	{
	public:
		virtual void HandleCallHungUpL() = 0;
	};

/**
*
* @class	CPhoneCallMaker AnsPhoneCallMaker.h
* @brief	This class makes a phone call
*
*	An RCall handle is required to make the call. In order to open it, we need a handle on
*	an RLine handle. This will have been opened before this class is constructed and is passed
*	in as a parameter of the constructor.
*	
*	The MakeCallL() function is called in order to make the call.
*	This uses one of the RCall.DialL() functions. The RunL() function is called when the number 
*	has been dialled. At this point, we ask the RCall handle to notify us if a change occurs to 
*	its status, using NotifyStatusChange(). This will result in the RunL() function being
*	called when the status has changed. If the status is hanging up or idle, then we close the
*	RCall handle.
*	The observer is updated when the call has been hung up
*
* Copyright (c) EMCC Software Ltd 2003
* @version	1.0
*
*/

class CPhoneCallMaker : public CActive
	{
	public:
		static CPhoneCallMaker* NewL(MAnsPhoneCallMakerObserver& aObserver);
		~CPhoneCallMaker();

	public:				// CActive
		virtual void RunL();
		virtual void DoCancel();

	public:
		void MakeCallL(const TDesC& aNumber);

	private:
		//	the state of this object governs what happens when the
		//	StartL() / Stop() / RunL() / DoCancel() functions are called.
		enum TState	{ ENoState, EDialling, EWatching };

	private:
		CPhoneCallMaker(MAnsPhoneCallMakerObserver& aObserver);
		void ConstructL();

	private:
		void StartL();
		void Stop();
		void TelStartL();
		void TelCloseL();
	private:
		MAnsPhoneCallMakerObserver&	iObserver;
		RCall						iCall;
		RCall::TStatus				iCallStatus;
		TState						iState;
        TBuf<30>                    iNumber;

		// telephony
		RTelServer					iSession;
		RLine						iLine;
		RPhone						iPhone;
	};

#endif
